import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'

import { People } from './people.entity'

@Entity({ name: 'phone' })
export class Phone {
    //自增列
    @PrimaryGeneratedColumn()
    id: number
    //普通列
    @Column()
    name: string

    @Column()
    number: string

    // cascade: true, eager: true主实体设置就行
    // 如果要关联删除，两边都要设置{ onUpdate: 'CASCADE', onDelete: 'CASCADE' }
    @ManyToOne(() => People, people => people.phones, { onUpdate: 'CASCADE', onDelete: 'CASCADE' })
    people: People
}